var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  e = require("../../../utils/http"),
  a = t(require("../../../utils/util")),
  n = new e.HTTP;
Page({
  data: {
    xuzu: !0,
    ydsj: "请选择预定时间",
    daoqishow: !1,
    time: (new Date).getTime(),
    currentDate: (new Date).getTime(),
    currentDates: (new Date).getTime(),
    minDate: new Date(2022, 0, 1).getTime(),
    minDates: new Date(2022, 0, 1).getTime(),
    formatter: function (t, e) {
      return "year" === t ? "".concat(e, "年") : "month" === t ? "".concat(e, "月") : e
    },
    formatters: function (t, e) {
      return "year" === t ? "".concat(e, "年") : "month" === t ? "".concat(e, "月") : e
    },
    show: !1,
    mask: !1,
    yuding: "预定",
    showTime: !0,
    showTimes: !1
  },
  quxiao: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  formSubmit: function (t) {
    var e = t.detail.value,
      a = this;
    wx.showModal({
      title: "提示",
      content: "请核对数据是否确定修改",
      success: function (t) {
        if ("" == e.zsy || "" == e.qymc)
          wx.showToast({
            title: "请检查是否填写必填项",
            icon: "none",
            duration: 1500
          });
        else if (t.confirm) {
          if (1 == a.data.xuzu) {
            n.request({
                url: "https://www.qlsyyun.com:3000/renting",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  ycID: a.data.cID,
                  zsy: e.zsy,
                  ydsj: a.data.time,
                  qymc: e.qymc,
                  ztbz: e.ztbz,
                  gxname: a.data.tname,
                  czzk: a.data.yuding
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/sendMessage",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  qymc: e.qymc,
                  zsy: e.zsy,
                  ycID: a.data.cID,
                  tname: a.data.tname,
                  lc: e.lc,
                  fjh: e.fjh,
                  tjsj: a.data.tjsj,
                  zt: a.data.zt,
                  shijian: a.data.shijian
                }
              }).then((function (t) {})),
              wx.navigateBack({
                delta: 1
              });
            var s = getCurrentPages();
            s[s.length - 2].setData({
              yuding: "已预定"
            })
          }
          a.data.xuzu || n.request({
            url: "https://www.qlsyyun.com:3000/xuzu",
            header: {
              "Content-Type": "application/x-www-form-urlencoded"
            },
            method: "POST",
            data: {
              fz: e.fz,
              wy: e.wy,
              htks: a.data.htks,
              htdq: a.data.htdq,
              qymc: e.qymc,
              zsy: e.zsy,
              bm: a.data.bm,
              bz: e.ztbz,
              cID: a.data.cID,
              rzrq: a.data.rzrq,
              gxname: a.data.tname,
              mj: a.data.ymj,
              fjbh: a.data.fjbh
            }
          }).then((function (t) {
            var s = new Date(1e3 * parseInt(a.data.tjsj)).toLocaleString().replace(/:\d{1,2}$/, " ").slice(0, 10).replace("上", "").replace("下", "");
            n.request({
                url: "https://www.qlsyyun.com:3000/xuzustmx",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  qymc: e.qymc,
                  zsy: e.zsy,
                  bm: a.data.bm,
                  cID: a.data.cID,
                  tjsj: a.data.tjsj,
                  tname: a.data.tname,
                  lb: "载体续签",
                  zt: a.data.zt,
                  lc: a.data.lc,
                  fjh: a.data.fjh,
                  crsj: s
                }
              }).then((function (t) {})),
              n.request({
                url: "https://www.qlsyyun.com:3000/xuzustqyy",
                header: {
                  "Content-Type": "application/x-www-form-urlencoded"
                },
                method: "POST",
                data: {
                  fz: e.fz,
                  wy: e.wy,
                  htks: a.data.htks,
                  htdq: a.data.htdq,
                  qymc: e.qymc,
                  zsy: e.zsy,
                  bm: a.data.bm,
                  bz: e.ztbz,
                  gxname: a.data.tname,
                  fjbh: a.data.fjbh
                }
              }).then((function (t) {
                wx.showToast({
                  title: "续租成功",
                  icon: "none",
                  duration: 500,
                  success: function () {
                    wx.navigateBack({
                      delta: 1
                    })
                  }
                })
              }))
          }))
        } else
          t.cancel && console.log("用户点击取消")
      }
    })
  },
  onInput: function (t) {
    var e = Date.parse(new Date(t.detail)) / 1e3,
      a = new Date(1e3 * parseInt(e)).toLocaleString().replace(/:\d{1,2}$/, " ").slice(0, 10).replace("上", "").replace("下", "");
    this.setData({
      currentDate: t.detail,
      time: e,
      ydsjs: a
    })
  },
  onConfirm: function (t) {
    var e = a.default.formatStamp(t.detail);
    this.setData({
      show: !1,
      mask: !1,
      ydsj: this.data.time,
      showTimes: !0,
      showTime: !1,
      htks: e
    })
  },
  onConfirms: function (t) {
    this.setData({
      show: !1,
      mask: !1,
      daoqishow: !1,
      htdq: time
    })
  },
  onCancel: function () {
    this.setData({
      show: !1,
      daoqishow: !1,
      mask: !1,
      ydsj: "请填写预定时间"
    })
  },
  ydsjInput: function () {
    this.setData({
      ydsj: "",
      show: !0,
      mask: !0
    })
  },
  closeTime: function () {
    this.setData({
      mask: !1
    })
  },
  xuqiankaishi: function () {
    this.setData({
      show: !0
    })
  },
  xuqiandaoqi: function () {
    this.setData({
      daoqishow: !0
    })
  },
  onLoad: function (t) {
    var e = wx.getStorageSync("redact"),
      a = wx.getStorageSync("user"),
      n = new Date(1e3 * parseInt(Date.parse(new Date((new Date).getTime())) / 1e3)).toLocaleString().replace(/:\d{1,2}$/, " ").slice(0, 10).replace("上", ""),
      s = Date.parse(new Date((new Date).getTime())) / 1e3;
    console.log(n, "nowtime"),
      this.setData({
        zt: e.zt,
        lc: e.lc,
        fjh: e.fjh,
        fjbh: e.fjbh,
        zsy: e.zsy,
        ydsj: "请选择预定时间",
        qymc: e.qymc,
        ztbz: e.ztbz,
        cID: e.ycID,
        tname: a[0],
        shijian: n,
        tjsj: s,
        bm: a[1],
        ymj: e.ymj,
        htks: e.htks,
        htdq: e.htdq,
        fz: e.fz,
        wy: e.wy,
        rzrq: e.rzrq
      }),
      "空房" == e.czzk && this.setData({
        xuzu: !0
      }),
      "已出租" == e.czzk && this.setData({
        xuzu: !1
      }),
      console.log(e.czzk)
  }
});